//
//  OosServiceFeedParser.m
//  Oos4ios
//
//  Created by Pablo Gonzalez on 3/23/11.
//  Copyright 2011 11870.com. All rights reserved.
//

#import "OosServiceFeedParser.h"
#import "../Utils/OosEnum+Internal.h"
#import "OosLocationParser.h"
#import "../Atom/Feeds/OosServiceFeed.h"
#import "../Atom/Feeds/OosFeed.h"
#import "../Atom/Entries/OosServiceEntry.h"

#import "OosServiceEntryParser.h"

@implementation OosServiceFeedParser

static OosServiceFeedParser *instance;

+ (OosServiceFeedParser *) instance
{
	if (!instance) {
		instance = [[OosServiceFeedParser alloc] init];
	}
	return instance;
}

- (NSArray *) parseFeed:(OosFeed *)feed
{
	OosServiceFeed *serviceFeed = (OosServiceFeed *)feed;
	
	NSMutableArray *results;
	results = [NSMutableArray array];
	
	OosService *service;
	// iterate over the entries in the feed
	for (OosServiceEntry *entry in [serviceFeed entries]) {
		// TODO: check if service exists
		service = [[OosServiceEntryParser instance] parseEntry: entry];
		[results addObject: service];
	}
	return results;
}

@end
